home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************************\
- | |
- | HMarqueeCaption.h ©1997 John C. Daub. All rights reserved. |
- | See the file "HMarqueeCaption README" for full details, instructions, |
- | changes, licensing agreement, etc. Due to the important information |
- | included in that file, if you did not receive a copy of it, please contact |
- | the author for a copy. |
- | |
- | John C. Daub <mailto:hsoi@eden.com> |
- | <http://www.eden.com/~hsoi/> <http://www.eden.com/~hsoi/prog.html> |
- | |
- \*******************************************************************************/
-
-
- #ifndef _H_HMarqueeCaption
- #define _H_HMarqueeCaption
- #pragma once
-
-
- #if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
- #pragma import on
- #endif
-
-
- #include <PP_Prefix.h>
- #include <LPane.h>
- #include <LPeriodical.h>
- #include <LStream.h>
- #include <UMemoryMgr.h>
-
- #ifndef __QUICKDRAW__
- #include <QuickDraw.h>
- #endif
-
- #ifndef __QDOFFSCREEN__
- #include <QDOffscreen.h>
- #endif
-
-
- class HMarqueeCaption : public LPane,
- public LPeriodical
- {
-
- public:
-
- enum { class_ID = 'MQcp' };
-
- #if ( __PowerPlant__ < 0x01608000 ) // version 1.6/CW11
- static HMarqueeCaption* CreateFromStream(LStream *inStream);
- #endif
-
-
- HMarqueeCaption();
- HMarqueeCaption(const HMarqueeCaption &inOriginal);
- HMarqueeCaption(const SPaneInfo &inPaneInfo,
- ResIDT inTextID,
- ResIDT inTextTraitsID,
- Int16 inDelay = 1,
- Int16 inScrollAmount = 1,
- Boolean inResetOnResize = false );
- HMarqueeCaption(LStream *inStream);
- virtual ~HMarqueeCaption();
-
- HMarqueeCaption& operator=(const HMarqueeCaption &inOriginal);
-
- virtual void SpendTime( const EventRecord &inMacEvent );
- virtual void Draw( RgnHandle inSuperDrawRgnH );
-
- virtual ResIDT GetTextTraitsID() const;
- virtual void SetTextTraitsID( const ResIDT inTextTraitsID);
-
- virtual void StripCRLF();
-
- virtual void SetTextHandle( Handle inTextH );
-
- virtual ResIDT GetTextID() const;
- virtual void SetTextID( const ResIDT inTextID );
-
- virtual Uint16 GetDelay() const;
- virtual void SetDelay( const Uint16 inDelay );
-
- virtual Int16 GetScrollAmount() const;
- virtual void SetScrollAmount( const Int16 inScrollAmount );
-
- virtual Boolean GetResetOnResize() const;
- virtual void SetResetOnResize( const Boolean inResetOnResize );
-
- virtual void ResizeFrameBy(Int16 inWidthDelta, Int16 inHeightDelta,
- Boolean inRefresh);
-
-
- protected:
-
- virtual void DrawSelf();
- virtual void ActivateSelf();
- virtual void DeactivateSelf();
-
- virtual void Reset();
-
- virtual void AllocateGWorld();
- virtual void DestroyGWorld();
-
- virtual Int16 GetStringHeight() const;
- virtual void SetStringHeight( const Int16 inHeight );
-
- virtual Int32 GetLastEvent() const;
- virtual void SetLastEvent( const Int32 inLastEvent );
-
- virtual Uint32 GetTextLength() const;
- virtual void SetTextLength();
- virtual void SetTextLength( const Uint32 inLength );
-
- virtual Int16 GetOffset() const;
- virtual void SetOffset( const Int16 inOffset );
- virtual void IncrementOffset( const Int16 inDelta );
-
- private:
-
- void InitMarqueeCaption();
-
- Int16 mStrHeight;
- Int32 mLastEvent;
- GWorldPtr mGWorld;
- Uint32 mTextLength;
- Int16 mOffset;
-
- Handle mTextH;
-
- ResIDT mTextID;
- ResIDT mTextTraitsID;
- Uint16 mDelay;
- Int16 mScrollAmount;
- Boolean mResetOnResize;
-
- };
-
-
- //============================================================================
- // ••• Inlines
- //============================================================================
-
- //============================================================================
- // • GetStringHeight [protected, virtual]
- //============================================================================
- // Return the height of the string
-
- inline
- Int16
- HMarqueeCaption::GetStringHeight() const
- {
- return mStrHeight;
- }
-
-
- //============================================================================
- // • SetStringHeight [protected, virtual]
- //============================================================================
- // Set the string height to the given value
-
- inline
- void
- HMarqueeCaption::SetStringHeight(
- const Int16 inHeight )
- {
- mStrHeight = inHeight;
- }
-
-
- //============================================================================
- // • GetLastEvent [protected, virtual]
- //============================================================================
- // Returns the time (in ticks) of the last event
-
- inline
- Int32
- HMarqueeCaption::GetLastEvent() const
- {
- return mLastEvent;
- }
-
-
- //============================================================================
- // • SetLastEvent [protected, virtual]
- //============================================================================
- // Set the time of the last event (in ticks)
-
- inline
- void
- HMarqueeCaption::SetLastEvent(
- const Int32 inLastEvent )
- {
- mLastEvent = inLastEvent;
- }
-
-
- //============================================================================
- // • GetTextLength [protected, virtual]
- //============================================================================
- // Return the length of the text string
-
- inline
- Uint32
- HMarqueeCaption::GetTextLength() const
- {
- return mTextLength;
- }
-
-
- //============================================================================
- // • SetTextLength [protected, virtual]
- //============================================================================
- // Set the length of the text string to the given value
-
- inline
- void
- HMarqueeCaption::SetTextLength(
- const Uint32 inLength )
- {
- mTextLength = inLength;
- }
-
-
- //============================================================================
- // • SetTextLength [protected, virtual]
- //============================================================================
- // Calculate the length of the text string and store the value
-
- inline
- void
- HMarqueeCaption::SetTextLength()
- {
- SignalIf_(mTextH == nil);
-
- StHandleLocker lock(mTextH);
- mTextLength = ::TextWidth( *mTextH, 0, ::GetHandleSize(mTextH) );
- }
-
-
- //============================================================================
- // • GetOffset [protected, virtual]
- //============================================================================
- // Return the offset
-
- inline
- Int16
- HMarqueeCaption::GetOffset() const
- {
- return mOffset;
- }
-
-
- //============================================================================
- // • SetOffset [protected, virtual]
- //============================================================================
- // Set the offset to the given amount
-
- inline
- void
- HMarqueeCaption::SetOffset(
- const Int16 inOffset )
- {
- mOffset = inOffset;
- }
-
-
- //============================================================================
- // • IncrementOffset [protected, virtual]
- //============================================================================
- // Increase the offset by the given amount (negative values will of course
- // decrease)
-
- inline
- void
- HMarqueeCaption::IncrementOffset(
- const Int16 inDelta )
- {
- mOffset += inDelta;
- }
-
-
- //============================================================================
- // • GetTextID [public, virtual]
- //============================================================================
- // Return the ResIDT of the 'TEXT' resource
-
- inline
- ResIDT
- HMarqueeCaption::GetTextID() const
- {
- return mTextID;
- }
-
-
- //============================================================================
- // • SetTextID [public, virtual]
- //============================================================================
- // Set the ResIDT of the 'TEXT' resource
-
- inline
- void
- HMarqueeCaption::SetTextID(
- const ResIDT inTextID )
- {
- mTextID = inTextID;
- }
-
-
- //============================================================================
- // • GetTextTraitsID [public, virtual]
- //============================================================================
- // Return the ResIDT of the 'Txtr' resource
-
- inline
- ResIDT
- HMarqueeCaption::GetTextTraitsID() const
- {
- return mTextTraitsID;
- }
-
- //============================================================================
- // • SetTextTraitsID [public, virtual]
- //============================================================================
- // Set the ResIDT to the given 'Txtr', and reset (since this could cause
- // enough graphical changes)
-
- inline
- void
- HMarqueeCaption::SetTextTraitsID(
- const ResIDT inTextTraitsID )
- {
- mTextTraitsID = inTextTraitsID;
- Reset();
- }
-
-
- //============================================================================
- // • GetDelay [public, virtual]
- //============================================================================
- // Return the delay amount (in ticks)
-
- inline
- Uint16
- HMarqueeCaption::GetDelay() const
- {
- return mDelay;
- }
-
-
- //============================================================================
- // • SetDelay [public, virtual]
- //============================================================================
- // Set the delay amount (in ticks) to the given amount
-
- inline
- void
- HMarqueeCaption::SetDelay(
- const Uint16 inDelay )
- {
- mDelay = inDelay;
- }
-
-
- //============================================================================
- // • GetScrollAmount [public, virtual]
- //============================================================================
- // Returns the scroll amount (in pixels)
-
- inline
- Int16
- HMarqueeCaption::GetScrollAmount() const
- {
- return mScrollAmount;
- }
-
-
- //============================================================================
- // • SetScrollAmount [public, virtual]
- //============================================================================
- // Set the scroll amount to the given number of pixels
-
- inline
- void
- HMarqueeCaption::SetScrollAmount(
- const Int16 inScrollAmount )
- {
- mScrollAmount = inScrollAmount;
- }
-
-
- //============================================================================
- // • GetResetOnResize [public, virtual]
- //============================================================================
- // Return true if we reset the caption upon resizing
-
- inline
- Boolean
- HMarqueeCaption::GetResetOnResize() const
- {
- return mResetOnResize;
- }
-
-
- //============================================================================
- // * SetResetOnResize [public, virtual]
- //============================================================================
- // Set to true if you wish to have the caption reset itself upon resizing
-
- inline
- void
- HMarqueeCaption::SetResetOnResize(
- const Boolean inResetOnResize )
- {
- mResetOnResize = inResetOnResize;
- }
-
-
-
- #if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
- #pragma import reset
- #endif
-
-
- #endif /* #define _H_HMarqueeCaption */